package com.example.xm.presenter.home;

import com.example.xm.base.BasePresenter;
import com.example.xm.bean.HomeBean.HomeYouHomeArticleBean;
import com.example.xm.bean.HomeBean.HomeYouHomeBean;
import com.example.xm.bean.HomeBean.HomeYouHomeExerciseBean;
import com.example.xm.bean.HomeBean.HomeYouHomeSocietyBean;
import com.example.xm.bean.HomeBean.HomeYouHomeTrendBean;
import com.example.xm.common.CommonSubScriBer;
import com.example.xm.interfaces.youhome.IYouHome;
import com.example.xm.model.HttpManager;
import com.example.xm.utiles.RxUtils;

public class YouHomePresenter extends BasePresenter<IYouHome.View> implements IYouHome.Presenter {
    @Override
    public void getYouHome() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getYouHome()
                .compose(RxUtils.<HomeYouHomeBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeYouHomeBean>(mView) {
                    @Override
                    public void onNext(HomeYouHomeBean homeYouHomeBean) {
                        mView.getYouHomeReturn(homeYouHomeBean);
                    }
                }));
    }

    @Override
    public void getTrends() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getTrend()
                .compose(RxUtils.<HomeYouHomeTrendBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeYouHomeTrendBean>(mView) {
                    @Override
                    public void onNext(HomeYouHomeTrendBean homeYouHomeTrendBean) {
                        mView.getTrends(homeYouHomeTrendBean);
                    }
                }));
    }

    @Override
    public void getExercise() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getExercise()
                .compose(RxUtils.<HomeYouHomeExerciseBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeYouHomeExerciseBean>(mView) {
                    @Override
                    public void onNext(HomeYouHomeExerciseBean homeYouHomeExerciseBean) {
                        mView.getExerciseReturn(homeYouHomeExerciseBean);
                    }
                }));
    }

    @Override
    public void getSociety() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getSociety()
                .compose(RxUtils.<HomeYouHomeSocietyBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeYouHomeSocietyBean>(mView) {
                    @Override
                    public void onNext(HomeYouHomeSocietyBean homeYouHomeSocietyBean) {
                        mView.getSocietyReturn(homeYouHomeSocietyBean);
                    }
                }));
    }

    @Override
    public void getArticle() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getArticle()
                .compose(RxUtils.<HomeYouHomeArticleBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeYouHomeArticleBean>(mView) {
                    @Override
                    public void onNext(HomeYouHomeArticleBean homeYouHomeArticleBean) {
                        mView.getArticleReturn(homeYouHomeArticleBean);
                    }
                }));
    }
}
